<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Rag Hu
 * Created Time: 2019/6/27 11:00
 * Modified Time: 2019/6/27 11:00
 * Version: 2.0
 */

namespace App\Modules\Service\Validators;


use Flower\Core\Repository\Contracts\ValidatorInterface;
use Flower\Core\Repository\Validator\LaravelValidator;

class ServiceValidator extends LaravelValidator
{
    protected $rules = [
        ValidatorInterface::RULE_CREATE => [
            'store_id' => 'required|numeric',
            'name' => 'required|between:2,8',
            'price' => 'required|numeric|min:1|max:99999',
            'royalty' => 'numeric|min:0|max:100',
            'type' => 'required|numeric',
            'cost' => 'numeric|min:0|max:99999',
        ],
        ValidatorInterface::RULE_UPDATE => [
            'name' => 'filled|between:2,8',
            'price' => 'filled|numeric|min:1|max:99999',
            'royalty' => 'filled|min:0|max:100',
            'type' => 'filled|numeric',
            'cost' => 'filled|numeric|min:0|max:100',
        ]
    ];
    protected $messages = [
        'store_id.required' => '店铺id不能为空',
        'store_id.numeric' => '店铺id格式错误',

        'name.required' => '请填写服务名称',
        'name.filled' => '请填写服务名称',
        'name.between' => '服务名称应在2-8个字符之间',

        'price.required' => '请填写服务价格',
        'price.filled' => '请填写服务价格',
        'price.numeric' => '服务价格格式错误',
        'price.min' => '服务价格不能低于1元',
        'price.max' => '服务价格不能高于99999元',

        'royalty.numeric' => '服务提成格式错误',
        'royalty.min' => '服务提成不能低于0%',
        'royalty.max' => '服务提成不能高于100%',

        'type.required' => '请选择服务类别',
        'type.filled' => '请选择服务类别',
        'type.numeric' => '服务类别格式错误',

        'cost.required' => '请填写服务成本',
        'cost.filled' => '请填写服务成本',
        'cost.numeric' => '服务成本格式错误',
        'cost.min' => '服务成本不能低于0%',
        'cost.max' => '服务成本不能高于100%',
    ];
}